require 'gamifier/model'

module Gamifier
  class ActivityDefinition < Model

    def limit(n_times, over_time)
      self.enable_rate_limiting = true
      self.bucket_max_capacity = n_times
      self.bucket_drain_rate = n_times.to_f / over_time.to_f
      self
    end

    def limit_per_day(times_per_day)
      limit(times_per_day, 24.0)
    end

    def limit_per_week(times_per_week)
      limit(times_per_week, 24.0 * 7.0)
    end

    def limit_once_per_day
      limit_per_day 1
    end

    def limit_once_per_week
      limit_per_week 1
    end

  end
end
